package com.ruoyi.resturant.service.Impl;

import com.ruoyi.common.exception.BizException;
import com.ruoyi.resturant.domain.ResBanner;
import com.ruoyi.resturant.mapper.ResBannerMapper;
import com.ruoyi.resturant.service.IResBannerService;
import com.ruoyi.resturant.service.IResDishService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ResBannerServiceImpl implements IResBannerService {
    private static final Logger log = LoggerFactory.getLogger(ResBannerServiceImpl.class);
    @Autowired
    private ResBannerMapper resBannerMapper;
    @Override
    public ResBanner selectResBannerById(Long id){
        return resBannerMapper.selectResBannerById(id);
    }
    @Override
    public List<ResBanner> selectResBannerByParam(String shopName){
        List<ResBanner> resBannerLst = resBannerMapper.selectResBannerByParam(shopName);
        return resBannerLst;
    }
    @Override
    public int insertResBanner(ResBanner resBanner){

        return resBannerMapper.insertResBanner(resBanner);
    }
    @Override
    public int updateResBanner(ResBanner resBanner){
        return resBannerMapper.updateResBanner(resBanner);
    }
    @Override
    public int deleteResBannerById(Long id){
        ResBanner resBanner = resBannerMapper.selectResBannerById(id);
        if(resBanner == null) {
            throw new BizException(404, "该轮播图ID" + id + "不存在");
        }
        log.info("该轮播图ID" + id + "存在");
        return resBannerMapper.deleteResBannerById(id);
    }
}
